package fun.yyds.controller.es;

import fun.yyds.common.ResponseData;
import fun.yyds.service.es.EsLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description: ES
 * @author: Chensn
 * @time: 2024/10/31
 */
@RestController
@Tag(name = "5.ES")
@RequestMapping("/es")
public class EsController {
    @Resource
    private EsLogService esLogService;


    @GetMapping("/log/page")
    @Operation(summary = "日志查询分页列表")
    public ResponseData logPage(@RequestParam(required = false) String keywords,
                                @RequestParam(required = false) String logType,
                                @RequestParam(defaultValue = "1") Integer currentPage,
                                @RequestParam(defaultValue = "10") Integer pageSize) {
        return ResponseData.success(esLogService.searchByMessage(keywords, logType, currentPage, pageSize));
    }

    @GetMapping("backup/log")
    @Operation(summary = "日志备份")
    public ResponseData backupLog() {
        return ResponseData.success(esLogService.backupLog());
    }
}
